package cn.com.suiyi.shixingshengxian.view;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ProgressBar;

public class CustomProgressBarUserLevel
        extends ProgressBar
{
    private Paint mPaint;
    private String text_progress;

    public CustomProgressBarUserLevel(Context paramContext)
    {
        super(paramContext);
        initPaint();
    }

    public CustomProgressBarUserLevel(Context paramContext, AttributeSet paramAttributeSet)
    {
        super(paramContext, paramAttributeSet);
        initPaint();
    }

    public CustomProgressBarUserLevel(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
    {
        super(paramContext, paramAttributeSet, paramInt);
        initPaint();
    }

    private void initPaint()
    {
        this.mPaint = new Paint();
        this.mPaint.setAntiAlias(true);
        this.mPaint.setColor(Color.BLACK);
    }

    private void setTextProgress(int paramInt)
    {
        paramInt = (int)(paramInt * 1.0F / getMax() * 100.0F);
        this.text_progress = "";
    }

    protected void onDraw(Canvas paramCanvas)
    {

            super.onDraw(paramCanvas);
            Rect localRect = new Rect();
            this.mPaint.getTextBounds(this.text_progress, 0, this.text_progress.length(), localRect);
            int i = getWidth() / 2;
            int j = localRect.centerX();
            int k = getHeight() / 2;
            int m = localRect.centerY();
            paramCanvas.drawText(this.text_progress, i - j, k - m, this.mPaint);
            return;

    }

    public void setProgress(int paramInt)
    {
        super.setProgress(paramInt);
            setTextProgress(paramInt);
            return;

    }
}
